/*
 *  Copyright 2002 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/*
 *  ======== thrProcess.h ========
 *
 */

#ifndef THRPROCESS_
#define THRPROCESS_

// RF5 module includes
#include <chan.h>
#include <icell.h>

#include "diff/cellDiff.h"
#include "rotate/cellRotate.h"
#include "appThreads.h"         // thread-wide common info

#ifdef __cplusplus
extern "C" {
#endif


/*********************************************
 * Specific to TI's DIFF algorithm
 *********************************************/
#define DIFF_NUMLINES      4  //process 8 lines at a time.

#define DIFF_NUMBLOCKS     (PROCF_HEIGHT / DIFF_NUMLINES)  

// Sizes of internal processing buffers (using double buffering)       
#define DIFF_Y_BUFSIZE          ((2 * PROCF_WIDTH) * DIFF_NUMLINES)
#define DIFF_CR_BUFSIZE         (((2 * PROCF_WIDTH) * DIFF_NUMLINES) >> 2)
#define DIFF_CB_BUFSIZE         (((2 * PROCF_WIDTH) * DIFF_NUMLINES) >> 2)


/*********************************************
 * Specific to TI's ROTATE algorithm
 *********************************************/
#define ROTATE_NUMLINES      4  //process 8 lines at a time.

#define ROTATE_NUMBLOCKS     (PROCF_HEIGHT / ROTATE_NUMLINES)  

// Sizes of internal processing buffers (using double buffering)       
#define ROTATE_Y_BUFSIZE          ((2 * PROCF_WIDTH) * ROTATE_NUMLINES)
#define ROTATE_CR_BUFSIZE         (((2 * PROCF_WIDTH) * ROTATE_NUMLINES) >> 2)
#define ROTATE_CB_BUFSIZE         (((2 * PROCF_WIDTH) * ROTATE_NUMLINES) >> 2)


// Pass-thru Channels
enum {  CHPASS0   = 0, 
		NUMPASSCHANS
     };

// Difference Channels
enum {  CHDIFF0   = 0, 
        NUMDIFFCHANS
     };

// Rotate Channels
enum {	CHROTATE  = 0,
		NUMROTATECHANS
	 };

// Combination Channels
enum {	CHCOMBO  = 0,
		NUMCOMBOCHANS
	 };
      
// Cells for Pass-thru
enum { CHPASSNUMCELLS  = 0
     };

// Cells for Difference
enum { CHDIFFCELLDIFF = 0,
       CHDIFFNUMCELLS
     };

// Cells for Rotate
enum { CHROTATECELLROTATE = 0,
       CHROTATENUMCELLS
     };

// Cells for Combo
enum { CHCOMBOCELLDIFF = 0,
       CHCOMBOCELLROTATE,
       CHCOMBONUMCELLS
     };


#define TOTALNUMCHANS (NUMPASSCHANS + NUMDIFFCHANS + NUMROTATECHANS + NUMCOMBOCHANS)

// message IDs
enum {
    MSGNEWRATIO = 0,
    MSGNEWREFERENCE,
    MSGNEWCOLOR
};

/* Definition of the structure describing the state of the thread. */
typedef struct ThrProcess {
    CHAN_Obj     	passChans[NUMPASSCHANS];		
    CHAN_Obj     	diffChans[NUMDIFFCHANS];
    CHAN_Obj     	rotateChans[NUMROTATECHANS];
    CHAN_Obj     	comboChans[NUMCOMBOCHANS];
    ICELL_Obj    	diffCells[NUMDIFFCHANS * CHDIFFNUMCELLS];
    ICELL_Obj    	rotateCells[NUMROTATECHANS * CHROTATENUMCELLS]; 
    ICELL_Obj    	comboCells[NUMCOMBOCHANS * CHCOMBONUMCELLS]; 
    DIFF_Env   	 	diffEnv[NUMDIFFCHANS + NUMCOMBOCHANS];
    ROTATE_Env	 	rotateEnv[NUMROTATECHANS + NUMCOMBOCHANS];
    placementBuff	OutputBuff;
    ScomProcToDisp 	scombufDisp;
    ScomCapToProc  	scombufCap;
} ThrProcess; 

/* prototypes for public functions */
extern Void thrProcessInit( Void );
extern Void thrProcessStartup( Void );
extern Void thrProcessRun( Void );

#ifdef __cplusplus
}
#endif // extern "C" 

#endif // THRPROCESS_



